package com.zhongkai.controller;

import com.zhongkai.app.service.IndentAuditService;
import com.zhongkai.model.utils.ZhongkaiResult;
import com.zhongkai.model3.Chinaset;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * 采购审批
 */

@Controller
public class IndentAuditController {

    @Autowired
    private IndentAuditService indentAuditService;



    /**
     * 审批
     *
     * @param id         商品id
     */
    @RequestMapping(value = "/indent_audit/ok", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_ok(@RequestParam(defaultValue = "0") Long id,
                                         HttpServletRequest httpServletRequest
    ) {


        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = indentAuditService.auditIndent_ok(id,chinaset.getSetName(), chinaset.getUuid());

        return result;
    }


    /**
     * 驳回
     *
     * @param id         商品id
     * @param ind_remark 驳回原因
     */
    @RequestMapping(value = "/indent_audit/error", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_error(@RequestParam(defaultValue = "0") Long id,  HttpServletRequest httpServletRequest,
                                            String ind_remark
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = indentAuditService.auditIndent_error(id,chinaset.getSetName(), chinaset.getUuid(),ind_remark);

        return result;
    }



    /**
     * 列表
     * @param page 页码
     * @param rows 条数
     */
    @RequestMapping(value = "/indent_audit/list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_list(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0")Integer rows
    ) {


        ZhongkaiResult result = indentAuditService.auditIndent_list(page,rows);

        return result;
    }


    //-----------------------办公采购--------------------------------------------------------------------------------

    /**
     * 审批
     *
     * @param id         商品id
     */
    @RequestMapping(value = "/indent_audit/ok2", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_ok2(@RequestParam(defaultValue = "0") Long id,
                                          HttpServletRequest httpServletRequest
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = indentAuditService.auditIndent_ok2(id,chinaset.getSetName(), chinaset.getUuid());

        return result;
    }


    /**
     * 驳回
     *
     * @param id         商品id
     * @param ind_remark 驳回原因
     */
    @RequestMapping(value = "/indent_audit/error2", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_error2(@RequestParam(defaultValue = "0") Long id,     HttpServletRequest httpServletRequest,
                                            String ind_remark
    ) {

        Chinaset chinaset = (Chinaset) httpServletRequest.getAttribute("user");
        ZhongkaiResult result = indentAuditService.auditIndent_error2(id,chinaset.getSetName(), chinaset.getUuid(),ind_remark);

        return result;
    }



    /**
     * 列表
     */
    @RequestMapping(value = "/indent_audit/list2", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult auditIndent_list2(@RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0")Integer rows
    ) {


        ZhongkaiResult result = indentAuditService.auditIndent_list2(page,rows);

        return result;
    }
}
